package com.mccken.designpattern.proxy.proxy1;

import com.mccken.designpattern.proxy.support.MetricsCollector;
import com.mccken.designpattern.proxy.support.RequestInfo;
import com.mccken.designpattern.proxy.support.UserVo;

/**
 * @program: mccken-collect
 * @description:
 * @author: mccken
 * @create: 2022-10-26 18:24
 **/
public class UserController {
	
	private MetricsCollector metricsCollector;
	
	public UserVo login(String telPhone, String password) {
		long startTimeStamp = System.currentTimeMillis();
		
		// todo 省略login逻辑
		
		// 
		
		long endTimeStamp = System.currentTimeMillis();
		long responseTime = startTimeStamp - endTimeStamp;
		RequestInfo requestInfo = new RequestInfo("login", responseTime, startTimeStamp);
		metricsCollector.recordRequest(requestInfo);
		
		return new UserVo();
	}
	
	public UserVo register(String telPhone, String password) {
		long startTimeStamp = System.currentTimeMillis();

		// todo 省略register逻辑

		long endTimeStamp = System.currentTimeMillis();
		long responseTime = startTimeStamp - endTimeStamp;
		RequestInfo requestInfo = new RequestInfo("register", responseTime, startTimeStamp);
		metricsCollector.recordRequest(requestInfo);

		return new UserVo();
	}
	
}
